﻿using System;
using System.Collections.Generic;
using System.Text;
using DataAccess;
using Entity;
using System.Data;
namespace BusinessObject
{
    public class NewsBO
    {
        NewsDA nDA = new NewsDA();
        public DataSet getNews()
        {
            DataSet dt = nDA.getNews();
            return dt;
        }

        public bool createNews(string title, string quickTitle, string images, string contents, int status)
        {
            News n = new News();
            n.New_Title = title;
            n.New_QuickTitle = quickTitle;
            n.New_Image = images;
            n.New_Content = contents;
            n.New_NStatus = status;

            if (nDA.CreateNews(n))
            {
                return true;
            }
            return false;
        }

        public News selectNewByID(int n)
        {
            News news = nDA.getNewByID(n);
            return news;
        }

        public bool updateNews(News n)
        {
            if (nDA.UpdateNews(n))
            {
                return true;
            }
            return false;
        }

        public bool removeNews(News n)
        {
            if (nDA.DeleteNews(n))
            {
                return true;
            }
            return false;
        }

        //lay 1 tin tuc theo status
        public DataSet getTopNewByStatus(int status)
        {
            DataSet dt = nDA.getTopNewsByStatus(status);
            return dt;
        }
        //lay tin tuc theo status
        public DataSet getTT_TDDU(int status)
        {
            DataSet dt = nDA.getTitleByStatus(status);
            return dt;
        }

        public DataSet getTitleByStatus(int status)
        {
            DataSet dt = nDA.getTitleByStatus(status);
            return dt;
        }
        //phan trang
        public DataSet getNewByStatus(int currPage, int recodperpage, int Pagesize, int status)
        {
            DataSet dt = nDA.getNewByStatus(currPage,recodperpage,Pagesize,status);
            return dt;
        }
    }
}
